<?php 
include("admin/sesiune.php");
?>

<a href="admin/adminPage.php"><input type="button" value="Back!"/></a>
<?php
$viewComenzi = "SELECT * FROM comenzi";
$viewProduse = mysql_query($viewComenzi,getConnection()) or die (mysql_error());
$nr = mysql_num_rows($viewProduse);

if($nr>0)
	{
		while ($viewProd= mysql_fetch_array($viewProduse)) 
		{	
			echo "<table><tr><td>Produs</td><td>$viewProd[pr_id]</td></tr><tr><td>User</td><td>$viewProd[username]</td></tr><tr><td>ID comanda : </td><td>$viewProd[com_id]</td></tr></table>"."<br/>"; 
		
			
			?>
<form method="post" action="delComanda.php">
<input type="hidden" name = "com_id" value="<?php echo $viewProd["com_id"];?>"/>
<input type="submit" value="Delete comand!" name="delete" onclick="return confirm('Are you sure you want to delete?')"/>
<input type="submit" value="Finalizata!" name="final" onclick="return confirm('Are you sure you want to delete?')"/>
</form>
<?php
if (isset($_POST['delete']))
{
echo "<input type='submit' value='Delete comand!' name='delete' onclick='return confirm('Are you sure you want to delete?')'/>";
} 
if (isset($_POST['final']))
{
echo "<input type='submit' value='Finalizata!' name='final' onclick='return confirm('Are you sure you want to delete?')'/>";
}
?>
		<?php 
		}		
	}
	
		elseif($_SESSION["username"])
		{
			echo "<div style='background:red;color:white;font-weight:bold;'>Nu exista produse</div>";
		}
 
?>
